/*  1:   */ package org.intellij.plugins.relaxNG.compact.psi.impl;
/*  2:   */ 
/*  3:   */

import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.util.IncorrectOperationException;
import org.intellij.plugins.relaxNG.compact.RncTokenTypes;
import org.intellij.plugins.relaxNG.compact.psi.RncDecl;
import org.intellij.plugins.relaxNG.compact.psi.RncElementVisitor;
import org.intellij.plugins.relaxNG.compact.psi.util.EscapeUtil;
import org.intellij.plugins.relaxNG.compact.psi.util.RenameUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */
/* 11:   */
/* 12:   */
/* 13:   */ 
/* 14:   */ public class RncDeclImpl
/* 15:   */   extends RncElementImpl
/* 16:   */   implements RncDecl
/* 17:   */ {
/* 18:   */   public RncDeclImpl(ASTNode paramASTNode)
/* 19:   */   {
/* 20:37 */     super(paramASTNode);
/* 21:   */   }
/* 22:   */   
/* 23:   */   public String getPrefix()
/* 24:   */   {
/* 25:41 */     ASTNode localASTNode = a();
/* 26:42 */     return localASTNode != null ? EscapeUtil.unescapeText(localASTNode) : null;
/* 27:   */   }
/* 28:   */   
/* 29:   */   public String getDeclaredNamespace()
/* 30:   */   {
/* 31:46 */     ASTNode localASTNode = getNode().findChildByType(RncTokenTypes.LITERAL);
/* 32:47 */     return localASTNode != null ? EscapeUtil.parseLiteralValue(localASTNode) : null;
/* 33:   */   }
/* 34:   */   
/* 35:   */   public int getTextOffset()
/* 36:   */   {
/* 37:52 */     ASTNode localASTNode = a();
/* 38:53 */     if (localASTNode != null) {
/* 39:54 */       return localASTNode.getStartOffset();
/* 40:   */     }
/* 41:56 */     return super.getTextOffset();
/* 42:   */   }
/* 43:   */   
/* 44:   */   private ASTNode a()
/* 45:   */   {
/* 46:61 */     ASTNode localASTNode = getNode().findChildByType(RncTokenTypes.IDENTIFIERS);
/* 47:62 */     if (localASTNode == null)
/* 48:   */     {
/* 49:63 */       ASTNode[] arrayOfASTNode = getNode().getChildren(RncTokenTypes.KEYWORDS);
/* 50:64 */       if (arrayOfASTNode.length > 1) {
/* 51:65 */         return arrayOfASTNode[1];
/* 52:   */       }
/* 53:   */     }
/* 54:68 */     return localASTNode;
/* 55:   */   }
/* 56:   */   
/* 57:   */   public String getName()
/* 58:   */   {
/* 59:73 */     String str = getPrefix();
/* 60:74 */     return str != null ? str : "";
/* 61:   */   }
/* 62:   */   
/* 63:   */   public PsiElement setName(@NonNls @NotNull String paramString)
/* 64:   */     throws IncorrectOperationException
/* 65:   */   {
/* 66:78 */     if (paramString == null) {
/* 67:78 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/plugins/relaxNG/compact/psi/impl/RncDeclImpl", "setName" }));
/* 68:   */     }
/* 69:78 */     ASTNode localASTNode = a();
/* 70:79 */     if (localASTNode == null) {
/* 71:79 */       return this;
/* 72:   */     }
/* 73:80 */     localASTNode.getTreeParent().replaceChild(localASTNode, RenameUtil.createIdentifierNode(getManager(), paramString));
/* 74:81 */     return this;
/* 75:   */   }
/* 76:   */   
/* 77:   */   public void accept(@NotNull RncElementVisitor paramRncElementVisitor)
/* 78:   */   {
/* 79:85 */     if (paramRncElementVisitor == null) {
/* 80:85 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/plugins/relaxNG/compact/psi/impl/RncDeclImpl", "accept" }));
/* 81:   */     }
/* 82:85 */     paramRncElementVisitor.visitElement(this);
/* 83:   */   }
/* 84:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.plugins.relaxNG.compact.psi.impl.RncDeclImpl

 * JD-Core Version:    0.7.0.1

 */